/*
 * Copyright (C) 2009 Rob Cash
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * LocalFileMessageStoreLocation.java
 * 
 * Created on Jan 17, 2009 at 8:49:51 AM
 */

package org.robcash.apps.messagepopup.vo.impl;

import java.net.URL;
import org.robcash.apps.messagepopup.vo.MessageStoreLocation;

/**
 * Location of a local file message store
 * @author Rob
 */
public class RemoteFileMessageStoreLocation implements MessageStoreLocation {

    /**
     * Remote file
     */
    private URL remoteFile;

    /**
     * Create a new remote file message store location
     */
    public RemoteFileMessageStoreLocation() {}

    /**
     * Create a new remote file message store location
     * @param remoteFile Remote file where the message store is located
     */
    public RemoteFileMessageStoreLocation(URL remoteFile) {
        this.remoteFile = remoteFile;
    }

    /**
     * Get the remote file where the message store is located
     * @return Remote file where the message store is located
     */
    public URL getRemoteFile() {
        return remoteFile;
    }

    /**
     * Get the remote file where a message store is located
     * @param remoteFile Remote file where a message store is located
     */
    public void setRemoteFile(URL remoteFile) {
        this.remoteFile = remoteFile;
    }

    @Override
    public String toString() {
        if ( remoteFile != null ) {
            return remoteFile.toString();
        }
        else {
            return "";
        }
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final RemoteFileMessageStoreLocation other = (RemoteFileMessageStoreLocation) obj;
        if (this.remoteFile != other.remoteFile && (this.remoteFile == null || !this.remoteFile.equals(other.remoteFile))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 37 * hash + (this.remoteFile != null ? this.remoteFile.hashCode() : 0);
        return hash;
    }

}
